package registry

import (
	"starsine.cn/appTpl/cmn/config/aconf"
	. "starsine.cn/appTpl/cmn/defs"
	"starsine.cn/appTpl/cmn/logs"
	grpcserver "starsine.cn/appTpl/svccenter/registry/grpc/server"
	"starsine.cn/appTpl/svccenter/registry/registrypubsub"
	"starsine.cn/appTpl/svccenter/registry/restful/chan2svc"
	restfulserver "starsine.cn/appTpl/svccenter/registry/restful/server"
	"starsine.cn/appTpl/svccenter/registry/restful/token"
	"starsine.cn/appTpl/svccenter/registry/restful/ws-server"
	"starsine.cn/appTpl/svccenter/registry/svcmng"
)

func Start(appCtxt *AppContext) {
	registrypubsub.Start()

	mode := aconf.GetString("SvcCenter.RegistryMode", "grpc", aconf.WithENV("sc_mode"))
	if mode == "ws" {
		ws.Start(appCtxt)
		token.Start()
		chan2svc.Start()
		restfulserver.Start(appCtxt)
	} else {
		grpcserver.Start()
	}
	svcmng.Start(appCtxt, mode == "grpc")

	logs.Infof("registry(rpcMode: %s) start", mode)
}
